home *** CD-ROM | disk | FTP | other *** search
- /***************************************************************************
-
- TileHack, an FKEY
-
- A Hack that changed, and changed again. This hack is now called
- You Got No Fonts, You Skanky Programmer
-
- This hack uses the concept of the FKEY as a way to quickly change
- your reality. Think dose, think FKEY.
-
- We actually use NO RESOURCES. This is essential to the self-contained
- hack FKEY 'You Got No Fonts, You Skanky Programmer'.
-
- We want a very cool Window, made from the very stuff of code itself,
- LetterForm. So we take Outline fonts, make a Picture, turn it into
- a RegionHandle with an offscreen port, write it to a resource, turn
- the resource into a buncha DC.W's (the skanky programmers friend)
- and embed them into the CODE itself (like the old days). ALL
- creation code is in the FKEY, toggled by a compile-time flag.
-
- When we fire off the FKEY, we make a window, invisible, BlockMove the
- WDEF code, STUFF the windowProc, ShowWindow and leave the scene of the crime.
-
- Don't try this at home, You Skanky Programmer (NOT! :-)
-
- B. Marshall Hamlin
- Constructor
- Noesis Sfwr Construction
-
- ALink: D0781
- 6300 Leona St
- Oakland, CA 94605-1228
-
- ***************************************************************************/
- // I N C L U D E
- //include "LoMem.ph"
- #include <LoMem.h>
- #include <Resources.h>
- #include <Palettes.h>
-
-
- //*************************************************************************
- // F O R W A R D
-
- pascal void FlushCodeCache (void) = 0xA0BD;
-
- pascal long HackWindow (short varCode, WindowPeek theWindow, short message, long param);
-
- void dataShortProc(void);
- void endShortData(void);
-
- void dataLongProc(void);
- void endLongData(void);
-
- void DrawHackCont(void);
- void MakeRgnBg(void);
- RgnHandle PICT2Rgn( PicHandle p );
- BitMap *PICT2BitMap( PicHandle p );
- Boolean CreateOffscreenBitMap(GrafPtr *newOffscreen, Rect *inBounds);
- void DestroyOffscreenBitMap(GrafPtr oldOffscreen);
-
-
-
- //*************************************************************************
- // C O N S T A N T S
-
- #define kWinLongHdrHt 98
- #define kWinLongWid 502
- #define kWinLongHt (407-kWinHdrHt)
-
- #define kWinShortHdrHt 96
- #define kWinShortWid 275
-
-
- typedef struct {
- char privates[76];
- long randSeed;
- BitMap screenBits;
- Cursor arrow;
- Pattern dkGray;
- Pattern ltGray;
- Pattern gray;
- Pattern black;
- Pattern white;
- GrafPtr thePort;
- }QD;
-
-
- //*************************************************************************
- // F L A G S
-
- #define MAKE_RGN 0
-
-
- //*************************************************************************
- // M A I N
- main()
- {
- SysEnvRec environs;
- GrafPtr savPort;
-
- QD *qdG;
-
- OSErr err;
- WindowPeek thWinPtr;
- Ptr wdefProcPtr;
- Rect bounds;
- short off1, off2;
- unsigned long prevA5;
- long procSize;
- struct { short jmp ;
- ProcPtr addr ;} **wdefHdl;
-
- // *************************************************************
- // Insert a set of routines to build the Window Region
-
- if ( MAKE_RGN) {
- MakeRgnBg();
- return;
- }
-
- // *************************************************************
- // Check for color (make one in B&W, later)
-
- err = SysEnvirons( 1, &environs);
- if (err != noErr || !environs.hasColorQD)
- return;
-
-
- // *************************************************************
- // Decide how big our display window is here
- // Should we:
- // make it a fixed size?
- // search monitors, find a good one, calc size and put it there?
-
- bounds.top = (**GrayRgn).rgnBBox.top + MBarHeight + 2;
- bounds.left = (**GrayRgn).rgnBBox.left + 2;
- bounds.right = bounds.left + kWinShortWid;
- bounds.bottom = bounds.top + kWinShortHdrHt; // + kWinHt;
-
- off1 = Random(); off1 = off1 & 0x001f;
- off2 = Random(); off2 = off2 & 0x001f;
-
- OffsetRect( &bounds, off1, off2);
-
- // *************************************************************
- // Make the window here. Make it invisible, so we can stuff
- // the WDEF. We could just pass a WDEF resId, but this is an
- // FKEY so we want to keep it _completely_ self-contained.
-
- GetPort( &savPort);
- thWinPtr = NewCWindow( nil, &bounds, "", false, 0, (void*)-1, true, 0L);
- procSize = (long)((Ptr)endLongData - (Ptr)HackWindow); // src dependent
-
- wdefHdl = NewHandle( procSize);
- BlockMove( (Ptr)HackWindow, *wdefHdl, procSize);
-
- if (CPUFlag >= 2) // programmers have 040's
- FlushCodeCache();
- thWinPtr->windowDefProc = wdefHdl;
- ShowWindow( thWinPtr);
-
-
- // *************************************************************
- // A5 Lore - it turns out that calling an FKEY under System VII
- // is done in such a way that moving from CurrentA5 is *not*
- // good enough to allow drawing. (the following code won't let
- // us draw) Neither will just drawing after the SetPort() for
- // matter...
- //
- //asm {
- // movea.l CurrentA5,A5
- //};
-
- // *************************************************************
- // SO what we do is allocate a quickdraw globals space on the
- // heap and call _InitGraf, thereby letting us do our drawing!
- // Be sure to save the OLD A5 and restore it to keep the world
- // in line.
- // CALLER BEWARE: since InitGraf fills storage from the *bottom
- // up*, we have to allocate a Ptr the right size & pass a Ptr to
- // the port at the *bottom*. (thanks to sp)
-
- #if(1)
- if ( (qdG = NewPtr( sizeof(QD))) != 0) {
- asm {
- move.l a5,prevA5
- };
- InitGraf( &qdG->thePort);
- SetPort( thWinPtr);
- DrawHackCont();
- asm {
- move.l prevA5,a5
- };
- SetPort( savPort);
- DisposPtr( qdG);
- }
- #else
- SetPort( savPort);
- #endif
-
- // *************************************************************
- // Ditch the window ? or leave it around... TBD
- // (different apps will respond in different ways to having an
- // alien window around)
-
- if ( 0) {
- while (!Button())
- ;
-
- SetPort( savPort);
- DisposeWindow( thWinPtr);
- DisposeHandle( wdefHdl);
- }
-
-
- }
-
- #if(0)
- // *************************************************************
- // Old way. Make a Ptr, stuff the WDEF, make a handle,
- // stuff a JMP and Ptr address (don't ask me, I just
- // made it work!)
-
- wdefProcPtr = NewPtr(procSize);
- BlockMove( (Ptr)HackWindow, wdefProcPtr, procSize);
-
- wdefHdl = NewHandle (sizeof(**wdefHdl));
-
- (**wdefHdl).jmp = 0x4EF9;
- (**wdefHdl).addr = wdefProcPtr;
-
- // Before that, I used the code *in* the FKEY, but that's
- // bad 'cause the FKEY will be moved/purged after you die..
- //(**wdefHdl).addr = &HackWindow;
- #endif
-
-
-
- //*************************************************************************
- // WDEF here.
- //*************************************************************************
- #define kNoGrowVar 1
-
- pascal long HackWindow( short varCode, WindowPeek theWindow, short message, long param)
- {
- Handle h, h2;
- Boolean growable;
- Rect r, bitsR;
- Point pt;
- long dataSize;
- CGrafPtr cGrafPtr;
- GrafPtr savPort;
-
- RGBColor tC;
- Pattern blk = { 0,0,0,0,0,0,0,0};
- Pattern wht = { 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff};
- Pattern gr = { 0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55};
-
-
- growable = (varCode != kNoGrowVar);
-
- switch (message) {
-
- case wDraw:
- // ************************************************************
- // DRAW
- // check the visible flag. If not visible, forget it!
-
- if ( !theWindow->visible)
- return;
-
- // ************************************************************
- // Next, check the value of param
- //
- // 0 Draw entire window frame
- // check hilite
- // check goAway flag in window record
- // check growable flag
- // 4 Handle goAway
- //
- // Note that drawing is clipped to the structure rgn
- //
-
- if ( param == 4) {
- // no go away right now
- break;
- }
-
-
- #if(1)
- //PenPat( gr);
-
- GetPort( &savPort);
- GetCWMgrPort( &cGrafPtr); // Most Necessary to draw in color
- SetPort( cGrafPtr);
- PenNormal();
-
- tC.red = Random(); //0x4400;
- tC.green = 0x0000;
- tC.blue = 0x0000;
- RGBForeColor( &tC);
- PaintRgn( theWindow->strucRgn);
-
- ForeColor( blackColor);
- FrameRgn( theWindow->strucRgn);
- FrameRect( &(**theWindow->contRgn).rgnBBox);
-
- BackColor( whiteColor);
- EraseRgn( theWindow->contRgn);
-
- if ( theWindow->hilited) {
- Rect r;
- short hL;
- short curPen;
- long indC[ 20] = {0,1,2,3,4,5,6,12,18,24,30,215,71,218,220,221,222,223,255};
- short *clutPtr; // ditch the type stuff
-
- // interesting indexes in the system clut
- // 0,1,2,3,4,5,6,12,18,24,30,215,71,218,220,221,222,223,255
-
- //DebugStr("\p;thecport");
-
- //tC.red = 0x4400;
- //tC.green = 0x0000;
- //tC.blue = 0x0000;
- //RGBForeColor( &tC);
- //PaintRgn( theWindow->strucRgn);
-
- if(0) {
- // ********************************************************
- // We want to draw in nice colors. Send this to me later!
-
- r = (**theWindow->strucRgn).rgnBBox;
- curPen = 2;
- PenSize( curPen, curPen);
-
- clutPtr = &(**(**cGrafPtr->portPixMap).pmTable).ctTable;
- Debugger();
-
- for( hL=0; hL<20; hL++) {
-
- Index2Color( indC[hL], &tC);
-
- //tC.red = clutPtr[ indC[hL]+1];
- //tC.green = clutPtr[ indC[hL]+2];
- //tC.blue = clutPtr[ indC[hL]+3];
-
- RGBForeColor( &tC);
- MoveTo( r.left+4, r.top+58+hL*curPen);
- Line( r.right-r.left-8, 0);
- MoveTo( r.left+4, r.top+58-hL*curPen);
- Line( r.right-r.left-8, 0);
- }
-
- //PenMode( patBic);
-
- //h2 = NewHandle( 0);
- //HandAndHand( theWindow->strucRgn, h2);
- //InsetRgn( (RgnHandle)h2, -2, -2);
- //PaintRgn( (RgnHandle)h2);
- }
-
- } else if ( growable) {
- }
- #else
- r = (**theWindow->strucRgn).rgnBBox;
- FrameRect( &r);
- #endif
- ForeColor( blackColor);
- PenNormal();
- SetPort( savPort);
-
- break;
-
-
- case wHit:
- // ************************************************************
- // HIT
-
- pt.v = (param & 0xFFFF0000) >> 0x10;
- pt.h = param & 0x0000FFFF;
- GlobalToLocal( &pt);
-
- if ( pt.v < kWinShortHdrHt)
- return wInDrag;
-
- //Debugger();
- if ( PtInRgn( pt, theWindow->contRgn))
- return wInContent;
-
- return wInGrow;
- return wNoHit;
- break;
-
-
- case wCalcRgns:
- // ************************************************************
- // CALC REGIONS
-
- // get our pre-calc'd region, stuff it and go
-
- dataSize = (long)((Ptr)endShortData - (Ptr)dataShortProc);
- h = NewHandle( dataSize);
- BlockMove( (Ptr)dataShortProc, *h, dataSize);
-
- r = theWindow->port.portRect;
- if ( (*(CWindowRecord*)theWindow).port.portVersion < 0)
- bitsR = (**(*(CWindowRecord*)theWindow).port.portPixMap).bounds;
- else
- bitsR = theWindow->port.portBits.bounds;
-
- DisposeRgn( theWindow->strucRgn);
- OffsetRgn( (RgnHandle)h, -bitsR.left, -bitsR.top);
- theWindow->strucRgn = (RgnHandle)h;
-
- OffsetRect( &r, -bitsR.left, -bitsR.top);
- r.top += kWinShortHdrHt;
- r.left += 3;
- r.right -= 2;
- r.bottom -= 2;
- OpenRgn();
- FrameRect(&r);
- CloseRgn( theWindow->contRgn);
-
- break;
-
-
- case wNew:
- // ************************************************************
- // NEW
- break;
-
- case wDispose:
- // ************************************************************
- // DISPOSE
- break;
-
- case wGrow:
- // ************************************************************
- // GROW
- if ( growable) {
- ;
- }
- break;
-
- case wDrawGIcon:
- // ************************************************************
- // DRAW GROW ICON
- break;
-
- default:
- break;
- };
- }
-
-
- /********************************************************************************
- dataShortProc
-
- Window with no content rgn
-
- *********************************************************************************/
-
- void dataShortProc()
- {
- asm {
- dc.w 0x07F0,0x0000,0x0000,0x0060,0x0113,0x0000
- dc.w 0x005A,0x0064,0x00A7,0x00AD,0x7FFF,0x0001
- dc.w 0x0053,0x005A,0x0064,0x006A,0x009E,0x00A7
- dc.w 0x00AD,0x00B6,0x7FFF,0x0002,0x0050,0x0053
- dc.w 0x006A,0x006E,0x009A,0x009E,0x00B6,0x00B9
- dc.w 0x7FFF,0x0003,0x004C,0x0050,0x006E,0x0071
- dc.w 0x0097,0x009A,0x00B9,0x00BC,0x7FFF,0x0004
- dc.w 0x004B,0x004C,0x0071,0x0073,0x0094,0x0097
- dc.w 0x00BC,0x00BE,0x7FFF,0x0005,0x0049,0x004B
- dc.w 0x0073,0x0075,0x0092,0x0094,0x00BE,0x00C0
- dc.w 0x7FFF,0x0006,0x0047,0x0049,0x0075,0x0077
- dc.w 0x0090,0x0092,0x00C0,0x00C2,0x7FFF,0x0007
- dc.w 0x0045,0x0047,0x0077,0x0078,0x008E,0x0090
- dc.w 0x00C2,0x00C3,0x7FFF,0x0008,0x0044,0x0045
- dc.w 0x0078,0x0079,0x008D,0x008E,0x00C3,0x00C4
- dc.w 0x7FFF,0x0009,0x0043,0x0044,0x0079,0x007A
- dc.w 0x008B,0x008D,0x00C4,0x00C5,0x7FFF,0x000A
- dc.w 0x0042,0x0043,0x007A,0x007C,0x008A,0x008B
- dc.w 0x00C5,0x00C6,0x7FFF,0x000B,0x0041,0x0042
- dc.w 0x0089,0x008A,0x00C6,0x00C7,0x7FFF,0x000C
- dc.w 0x0040,0x0041,0x005C,0x0061,0x007C,0x007D
- dc.w 0x0087,0x0089,0x00C7,0x00C8,0x7FFF,0x000D
- dc.w 0x005A,0x005C,0x0061,0x0063,0x007D,0x007E
- dc.w 0x0087,0x0088,0x7FFF,0x000E,0x003F,0x0040
- dc.w 0x0059,0x005A,0x0063,0x0064,0x007E,0x007F
- dc.w 0x0088,0x0089,0x00C8,0x00C9,0x7FFF,0x000F
- dc.w 0x003E,0x003F,0x0058,0x0059,0x0064,0x0066
- dc.w 0x007F,0x0080,0x7FFF,0x0010,0x003D,0x003E
- dc.w 0x0057,0x0058,0x0066,0x0067,0x0089,0x008A
- dc.w 0x00C9,0x00CA,0x7FFF,0x0011,0x0080,0x0081
- dc.w 0x008A,0x008B,0x009F,0x00A7,0x7FFF,0x0012
- dc.w 0x003C,0x003D,0x0056,0x0057,0x0067,0x0068
- dc.w 0x009D,0x009F,0x00A7,0x00AA,0x7FFF,0x0013
- dc.w 0x0081,0x0082,0x008B,0x008C,0x009A,0x009D
- dc.w 0x00AA,0x00AB,0x7FFF,0x0014,0x003B,0x003C
- dc.w 0x0068,0x0069,0x008C,0x008D,0x0098,0x009A
- dc.w 0x00AB,0x00AC,0x7FFF,0x0015,0x0055,0x0056
- dc.w 0x0082,0x0083,0x0097,0x0098,0x00AC,0x00AD
- dc.w 0x00CA,0x00CB,0x7FFF,0x0016,0x008D,0x008E
- dc.w 0x0095,0x0097,0x7FFF,0x0017,0x003A,0x003B
- dc.w 0x008E,0x008F,0x0093,0x0095,0x00AD,0x00AE
- dc.w 0x7FFF,0x0018,0x0054,0x0055,0x0083,0x0084
- dc.w 0x0092,0x0093,0x7FFF,0x0019,0x0069,0x006A
- dc.w 0x008F,0x0092,0x7FFF,0x001A,0x00CA,0x00CB
- dc.w 0x7FFF,0x001B,0x0039,0x003A,0x7FFF,0x001D
- dc.w 0x0084,0x0085,0x7FFF,0x001F,0x00AD,0x00AE
- dc.w 0x7FFF,0x0020,0x00C9,0x00CA,0x7FFF,0x0022
- dc.w 0x00AC,0x00AD,0x00C8,0x00C9,0x7FFF,0x0024
- dc.w 0x0054,0x0055,0x0069,0x006A,0x0084,0x0085
- dc.w 0x00AB,0x00AC,0x00C7,0x00C8,0x7FFF,0x0025
- dc.w 0x0039,0x003A,0x7FFF,0x0026,0x0055,0x0056
- dc.w 0x00AA,0x00AB,0x7FFF,0x0027,0x003A,0x003B
- dc.w 0x0068,0x0069,0x00C6,0x00C7,0x7FFF,0x0028
- dc.w 0x00A9,0x00AA,0x00C5,0x00C6,0x7FFF,0x0029
- dc.w 0x0056,0x0057,0x0067,0x0068,0x00A8,0x00A9
- dc.w 0x7FFF,0x002A,0x003B,0x003C,0x0057,0x0058
- dc.w 0x00C4,0x00C5,0x7FFF,0x002B,0x003C,0x003D
- dc.w 0x0058,0x0059,0x0066,0x0067,0x00A7,0x00A8
- dc.w 0x00C3,0x00C4,0x7FFF,0x002C,0x0059,0x005A
- dc.w 0x0064,0x0066,0x0083,0x0084,0x00A6,0x00A7
- dc.w 0x7FFF,0x002D,0x003D,0x003E,0x005A,0x005D
- dc.w 0x0061,0x0064,0x00C2,0x00C3,0x7FFF,0x002E
- dc.w 0x003E,0x003F,0x005D,0x0061,0x00A5,0x00A6
- dc.w 0x00C1,0x00C2,0x7FFF,0x002F,0x003F,0x0040
- dc.w 0x0082,0x0083,0x00A4,0x00A5,0x00C0,0x00C1
- dc.w 0x7FFF,0x0030,0x0040,0x0041,0x00A3,0x00A4
- dc.w 0x7FFF,0x0031,0x0041,0x0042,0x00A2,0x00A3
- dc.w 0x00BF,0x00C0,0x7FFF,0x0032,0x0000,0x0007
- dc.w 0x000E,0x0015,0x001E,0x0022,0x002E,0x0033
- dc.w 0x0042,0x0043,0x0081,0x0082,0x00A1,0x00A2
- dc.w 0x00BE,0x00BF,0x00D1,0x00D6,0x00DC,0x00E1
- dc.w 0x00E8,0x00ED,0x00F9,0x00FE,0x0103,0x0108
- dc.w 0x010C,0x0112,0x7FFF,0x0033,0x0007,0x0008
- dc.w 0x001D,0x001E,0x002C,0x002E,0x0033,0x0035
- dc.w 0x0043,0x0045,0x00BD,0x00BE,0x00F7,0x00F9
- dc.w 0x00FE,0x0100,0x010B,0x010C,0x0111,0x0112
- dc.w 0x7FFF,0x0034,0x000D,0x000E,0x0022,0x0023
- dc.w 0x002B,0x002C,0x0035,0x0036,0x0045,0x0046
- dc.w 0x0080,0x0081,0x00A0,0x00A1,0x00BC,0x00BD
- dc.w 0x00ED,0x00EE,0x00F6,0x00F7,0x0100,0x0101
- dc.w 0x0110,0x0111,0x7FFF,0x0035,0x001C,0x001D
- dc.w 0x002A,0x002B,0x0046,0x0048,0x009F,0x00A0
- dc.w 0x00BB,0x00BC,0x00E7,0x00E8,0x00F5,0x00F6
- dc.w 0x010A,0x010B,0x010F,0x0110,0x7FFF,0x0036
- dc.w 0x0008,0x0009,0x0029,0x002A,0x002F,0x0036
- dc.w 0x0048,0x004B,0x007F,0x0080,0x009E,0x009F
- dc.w 0x00BA,0x00BB,0x00F4,0x00F5,0x00FA,0x0101
- dc.w 0x010E,0x010F,0x7FFF,0x0037,0x000C,0x000D
- dc.w 0x0023,0x0024,0x002E,0x002F,0x004B,0x004E
- dc.w 0x009D,0x009E,0x00B9,0x00BA,0x00EE,0x00EF
- dc.w 0x00F9,0x00FA,0x0109,0x010A,0x7FFF,0x0038
- dc.w 0x001B,0x001C,0x001E,0x0020,0x0028,0x0029
- dc.w 0x002D,0x002E,0x004E,0x0052,0x0060,0x0064
- dc.w 0x007E,0x007F,0x009C,0x009D,0x00B8,0x00B9
- dc.w 0x00D6,0x00DC,0x00E6,0x00E7,0x00E9,0x00EB
- dc.w 0x00F3,0x00F4,0x00F8,0x00F9,0x0108,0x0109
- dc.w 0x010D,0x010E,0x7FFF,0x0039,0x0004,0x0005
- dc.w 0x0009,0x000A,0x000F,0x0010,0x0052,0x0060
- dc.w 0x009B,0x009C,0x010C,0x010D,0x7FFF,0x003A
- dc.w 0x000B,0x000C,0x001A,0x001B,0x001D,0x001E
- dc.w 0x0024,0x0025,0x0063,0x0064,0x007D,0x007E
- dc.w 0x009A,0x009B,0x00B7,0x00B8,0x00E5,0x00E6
- dc.w 0x00EF,0x00F0,0x010C,0x010D,0x7FFF,0x003B
- dc.w 0x0005,0x0006,0x0020,0x0021,0x007C,0x007D
- dc.w 0x0099,0x009A,0x00B6,0x00B7,0x00D6,0x00DC
- dc.w 0x00E8,0x00E9,0x00EB,0x00EC,0x010D,0x010E
- dc.w 0x7FFF,0x003C,0x000A,0x000B,0x000E,0x000F
- dc.w 0x001D,0x0021,0x0025,0x0026,0x0028,0x0029
- dc.w 0x0062,0x0063,0x0098,0x0099,0x00B5,0x00B6
- dc.w 0x00E8,0x00EC,0x00F0,0x00F1,0x00F3,0x00F4
- dc.w 0x0108,0x0109,0x7FFF,0x003D,0x0019,0x001A
- dc.w 0x002D,0x002E,0x0061,0x0062,0x007B,0x007C
- dc.w 0x0097,0x0098,0x00B4,0x00B5,0x00E4,0x00E5
- dc.w 0x00F8,0x00F9,0x0109,0x010A,0x010E,0x010F
- dc.w 0x7FFF,0x003E,0x0006,0x0007,0x000D,0x000E
- dc.w 0x002E,0x002F,0x007A,0x007B,0x0096,0x0097
- dc.w 0x00B3,0x00B4,0x00F9,0x00FA,0x010F,0x0110
- dc.w 0x7FFF,0x003F,0x0018,0x0019,0x001C,0x0022
- dc.w 0x0026,0x0027,0x0029,0x002A,0x002F,0x0036
- dc.w 0x0060,0x0061,0x0095,0x0096,0x00B2,0x00B3
- dc.w 0x00E3,0x00E4,0x00E7,0x00ED,0x00F1,0x00F2
- dc.w 0x00F4,0x00F5,0x00FA,0x0101,0x010A,0x010B
- dc.w 0x0110,0x0111,0x7FFF,0x0040,0x002A,0x002B
- dc.w 0x005F,0x0060,0x0079,0x007A,0x0094,0x0095
- dc.w 0x00B1,0x00B2,0x00F5,0x00F6,0x7FFF,0x0041
- dc.w 0x0007,0x0008,0x000C,0x000D,0x001B,0x001C
- dc.w 0x0022,0x0023,0x0027,0x0028,0x002B,0x002C
- dc.w 0x005E,0x005F,0x0078,0x0079,0x0093,0x0094
- dc.w 0x00B0,0x00B1,0x00E6,0x00E7,0x00F6,0x00F7
- dc.w 0x010B,0x010C,0x0111,0x0112,0x7FFF,0x0042
- dc.w 0x0017,0x0018,0x002C,0x002E,0x0034,0x0036
- dc.w 0x005D,0x005E,0x0077,0x0078,0x0092,0x0093
- dc.w 0x00AF,0x00B0,0x00E2,0x00E3,0x00ED,0x00EE
- dc.w 0x00F2,0x00F3,0x00F7,0x00F9,0x00FF,0x0101
- dc.w 0x010C,0x010D,0x0112,0x0113,0x7FFF,0x0043
- dc.w 0x0000,0x0004,0x0008,0x000C,0x0010,0x0015
- dc.w 0x0017,0x001B,0x0023,0x0028,0x002E,0x0034
- dc.w 0x005C,0x005D,0x0076,0x0077,0x0091,0x0092
- dc.w 0x00AE,0x00AF,0x00D1,0x00D6,0x00DC,0x00E1
- dc.w 0x00E2,0x00E6,0x00EE,0x00F3,0x00F9,0x00FF
- dc.w 0x0103,0x0108,0x010D,0x0113,0x7FFF,0x0044
- dc.w 0x005B,0x005C,0x0075,0x0076,0x0090,0x0091
- dc.w 0x00AD,0x00AE,0x7FFF,0x0045,0x005A,0x005B
- dc.w 0x0074,0x0075,0x008F,0x0090,0x00AC,0x00AD
- dc.w 0x7FFF,0x0046,0x0058,0x005A,0x0073,0x0074
- dc.w 0x008E,0x008F,0x00AB,0x00AC,0x7FFF,0x0047
- dc.w 0x0057,0x0058,0x0072,0x0073,0x008D,0x008E
- dc.w 0x00AA,0x00AB,0x7FFF,0x0048,0x0055,0x0057
- dc.w 0x0071,0x0072,0x008C,0x008D,0x00A9,0x00AA
- dc.w 0x7FFF,0x0049,0x0054,0x0055,0x0070,0x0071
- dc.w 0x008A,0x008C,0x00A9,0x00CC,0x7FFF,0x004A
- dc.w 0x0052,0x0054,0x006F,0x0070,0x0089,0x008A
- dc.w 0x7FFF,0x004B,0x0050,0x0052,0x006E,0x006F
- dc.w 0x0088,0x0089,0x7FFF,0x004C,0x004E,0x0050
- dc.w 0x006C,0x006E,0x0087,0x0088,0x7FFF,0x004D
- dc.w 0x004C,0x004E,0x006B,0x006C,0x0086,0x0087
- dc.w 0x7FFF,0x004E,0x0049,0x004C,0x0069,0x006B
- dc.w 0x0085,0x0086,0x7FFF,0x004F,0x0045,0x0049
- dc.w 0x0068,0x0069,0x0084,0x0085,0x7FFF,0x0050
- dc.w 0x0041,0x0045,0x0067,0x0068,0x7FFF,0x0051
- dc.w 0x0065,0x0067,0x7FFF,0x0052,0x0063,0x0065
- dc.w 0x7FFF,0x0053,0x0061,0x0063,0x7FFF,0x0054
- dc.w 0x005F,0x0061,0x7FFF,0x0055,0x005D,0x005F
- dc.w 0x7FFF,0x0056,0x005B,0x005D,0x7FFF,0x0057
- dc.w 0x0058,0x005B,0x7FFF,0x0058,0x0055,0x0058
- dc.w 0x7FFF,0x0059,0x0052,0x0055,0x7FFF,0x005A
- dc.w 0x004F,0x0052,0x7FFF,0x005B,0x004F,0x0084
- dc.w 0x7FFF,0x005C,0x004A,0x0084,0x7FFF,0x005D
- dc.w 0x004A,0x0084,0x7FFF,0x0060,0x0041,0x00CC
- dc.w 0x7FFF,0x7FFF
- };
- }
-
- void endShortData()
- {
- ;
- }
-
-
- /********************************************************************************
- dataLongProc
-
- Window with a content rgn
-
- *********************************************************************************/
-
- void dataLongProc()
- {
- asm {
- dc.w 0x0824,0x0000,0x0000,0x005F,0x01F7,0x0000
- dc.w 0x00CA,0x00D4,0x0117,0x011D,0x7FFF,0x0001
- dc.w 0x00C3,0x00CA,0x00D4,0x00DA,0x010E,0x0117
- dc.w 0x011D,0x0126,0x7FFF,0x0002,0x00C0,0x00C3
- dc.w 0x00DA,0x00DE,0x010A,0x010E,0x0126,0x0129
- dc.w 0x7FFF,0x0003,0x00BC,0x00C0,0x00DE,0x00E1
- dc.w 0x0107,0x010A,0x0129,0x012C,0x7FFF,0x0004
- dc.w 0x00BB,0x00BC,0x00E1,0x00E3,0x0104,0x0107
- dc.w 0x012C,0x012E,0x7FFF,0x0005,0x00B9,0x00BB
- dc.w 0x00E3,0x00E5,0x0102,0x0104,0x012E,0x0130
- dc.w 0x7FFF,0x0006,0x00B7,0x00B9,0x00E5,0x00E7
- dc.w 0x0100,0x0102,0x0130,0x0132,0x7FFF,0x0007
- dc.w 0x00B5,0x00B7,0x00E7,0x00E8,0x00FE,0x0100
- dc.w 0x0132,0x0133,0x7FFF,0x0008,0x00B4,0x00B5
- dc.w 0x00E8,0x00E9,0x00FD,0x00FE,0x0133,0x0134
- dc.w 0x7FFF,0x0009,0x00B3,0x00B4,0x00E9,0x00EA
- dc.w 0x00FB,0x00FD,0x0134,0x0135,0x7FFF,0x000A
- dc.w 0x00B2,0x00B3,0x00EA,0x00EC,0x00FA,0x00FB
- dc.w 0x0135,0x0136,0x7FFF,0x000B,0x00B1,0x00B2
- dc.w 0x00F9,0x00FA,0x0136,0x0137,0x7FFF,0x000C
- dc.w 0x00B0,0x00B1,0x00CC,0x00D1,0x00EC,0x00ED
- dc.w 0x00F7,0x00F9,0x0137,0x0138,0x7FFF,0x000D
- dc.w 0x00CA,0x00CC,0x00D1,0x00D3,0x00ED,0x00EE
- dc.w 0x00F7,0x00F8,0x7FFF,0x000E,0x00AF,0x00B0
- dc.w 0x00C9,0x00CA,0x00D3,0x00D4,0x00EE,0x00EF
- dc.w 0x00F8,0x00F9,0x0138,0x0139,0x7FFF,0x000F
- dc.w 0x00AE,0x00AF,0x00C8,0x00C9,0x00D4,0x00D6
- dc.w 0x00EF,0x00F0,0x7FFF,0x0010,0x00AD,0x00AE
- dc.w 0x00C7,0x00C8,0x00D6,0x00D7,0x00F9,0x00FA
- dc.w 0x0139,0x013A,0x7FFF,0x0011,0x00F0,0x00F1
- dc.w 0x00FA,0x00FB,0x010F,0x0117,0x7FFF,0x0012
- dc.w 0x00AC,0x00AD,0x00C6,0x00C7,0x00D7,0x00D8
- dc.w 0x010D,0x010F,0x0117,0x011A,0x7FFF,0x0013
- dc.w 0x00F1,0x00F2,0x00FB,0x00FC,0x010A,0x010D
- dc.w 0x011A,0x011B,0x7FFF,0x0014,0x00AB,0x00AC
- dc.w 0x00D8,0x00D9,0x00FC,0x00FD,0x0108,0x010A
- dc.w 0x011B,0x011C,0x7FFF,0x0015,0x00C5,0x00C6
- dc.w 0x00F2,0x00F3,0x0107,0x0108,0x011C,0x011D
- dc.w 0x013A,0x013B,0x7FFF,0x0016,0x00FD,0x00FE
- dc.w 0x0105,0x0107,0x7FFF,0x0017,0x00AA,0x00AB
- dc.w 0x00FE,0x00FF,0x0103,0x0105,0x011D,0x011E
- dc.w 0x7FFF,0x0018,0x00C4,0x00C5,0x00F3,0x00F4
- dc.w 0x0102,0x0103,0x7FFF,0x0019,0x00D9,0x00DA
- dc.w 0x00FF,0x0102,0x7FFF,0x001A,0x013A,0x013B
- dc.w 0x7FFF,0x001B,0x00A9,0x00AA,0x7FFF,0x001D
- dc.w 0x00F4,0x00F5,0x7FFF,0x001F,0x011D,0x011E
- dc.w 0x7FFF,0x0020,0x0139,0x013A,0x7FFF,0x0021
- dc.w 0x0000,0x00A9,0x00C4,0x00DA,0x00F5,0x011D
- dc.w 0x0139,0x01F7,0x7FFF,0x0022,0x0001,0x00A9
- dc.w 0x00C4,0x00DA,0x00F5,0x011C,0x0138,0x01F6
- dc.w 0x7FFF,0x0023,0x0002,0x00A9,0x00C4,0x00DA
- dc.w 0x00F5,0x011C,0x0138,0x01F5,0x7FFF,0x0025
- dc.w 0x0004,0x00AA,0x00C5,0x00D9,0x00F4,0x011B
- dc.w 0x0137,0x01F3,0x7FFF,0x0026,0x00C5,0x00C6
- dc.w 0x011A,0x011B,0x7FFF,0x0027,0x00AA,0x00AB
- dc.w 0x00D8,0x00D9,0x0136,0x0137,0x7FFF,0x0028
- dc.w 0x0119,0x011A,0x0135,0x0136,0x7FFF,0x0029
- dc.w 0x00C6,0x00C7,0x00D7,0x00D8,0x0118,0x0119
- dc.w 0x7FFF,0x002A,0x00AB,0x00AC,0x00C7,0x00C8
- dc.w 0x0134,0x0135,0x7FFF,0x002B,0x00AC,0x00AD
- dc.w 0x00C8,0x00C9,0x00D6,0x00D7,0x0117,0x0118
- dc.w 0x0133,0x0134,0x7FFF,0x002C,0x00C9,0x00CA
- dc.w 0x00D4,0x00D6,0x00F3,0x00F4,0x0116,0x0117
- dc.w 0x7FFF,0x002D,0x00AD,0x00AE,0x00CA,0x00CD
- dc.w 0x00D1,0x00D4,0x0132,0x0133,0x7FFF,0x002E
- dc.w 0x00AE,0x00AF,0x00CD,0x00D1,0x0115,0x0116
- dc.w 0x0131,0x0132,0x7FFF,0x002F,0x00AF,0x00B0
- dc.w 0x00F2,0x00F3,0x0114,0x0115,0x0130,0x0131
- dc.w 0x7FFF,0x0030,0x00B0,0x00B1,0x0113,0x0114
- dc.w 0x7FFF,0x0031,0x00B1,0x00B2,0x0112,0x0113
- dc.w 0x012F,0x0130,0x7FFF,0x0032,0x0070,0x0077
- dc.w 0x007E,0x0085,0x008D,0x0092,0x009F,0x00A3
- dc.w 0x00B2,0x00B3,0x00F1,0x00F2,0x0111,0x0112
- dc.w 0x012E,0x012F,0x0141,0x0146,0x014C,0x0151
- dc.w 0x0158,0x015D,0x016A,0x016E,0x0173,0x0178
- dc.w 0x017C,0x017E,0x7FFF,0x0033,0x0077,0x0078
- dc.w 0x009C,0x009F,0x00A3,0x00A6,0x00B3,0x00B5
- dc.w 0x012D,0x012E,0x0167,0x016A,0x016E,0x0171
- dc.w 0x017B,0x017C,0x017E,0x0181,0x7FFF,0x0034
- dc.w 0x007D,0x007E,0x0092,0x0093,0x009B,0x009C
- dc.w 0x00A5,0x00A6,0x00B5,0x00B6,0x00F0,0x00F1
- dc.w 0x0110,0x0111,0x012C,0x012D,0x015D,0x015E
- dc.w 0x0166,0x0167,0x0170,0x0171,0x0180,0x0181
- dc.w 0x7FFF,0x0035,0x008C,0x008D,0x009A,0x009B
- dc.w 0x00B6,0x00B8,0x010F,0x0110,0x012B,0x012C
- dc.w 0x0157,0x0158,0x0165,0x0166,0x017A,0x017B
- dc.w 0x017F,0x0180,0x7FFF,0x0036,0x0078,0x0079
- dc.w 0x0099,0x009A,0x009F,0x00A5,0x00B8,0x00BB
- dc.w 0x00EF,0x00F0,0x010E,0x010F,0x012A,0x012B
- dc.w 0x0164,0x0165,0x016A,0x0170,0x017E,0x017F
- dc.w 0x7FFF,0x0037,0x007C,0x007D,0x0093,0x0094
- dc.w 0x009E,0x009F,0x00BB,0x00BE,0x010D,0x010E
- dc.w 0x0129,0x012A,0x015E,0x015F,0x0169,0x016A
- dc.w 0x0179,0x017A,0x7FFF,0x0038,0x008B,0x008C
- dc.w 0x008E,0x0090,0x0098,0x0099,0x009D,0x009E
- dc.w 0x00BE,0x00C2,0x00D0,0x00D4,0x00EE,0x00EF
- dc.w 0x010C,0x010D,0x0128,0x0129,0x0146,0x014C
- dc.w 0x0156,0x0157,0x0159,0x015B,0x0163,0x0164
- dc.w 0x0168,0x0169,0x0178,0x0179,0x017D,0x017E
- dc.w 0x7FFF,0x0039,0x0074,0x0075,0x0079,0x007A
- dc.w 0x007F,0x0080,0x00C2,0x00D0,0x010B,0x010C
- dc.w 0x017C,0x017D,0x7FFF,0x003A,0x007B,0x007C
- dc.w 0x008A,0x008B,0x0094,0x0095,0x00D3,0x00D4
- dc.w 0x00ED,0x00EE,0x010A,0x010B,0x0127,0x0128
- dc.w 0x0155,0x0156,0x015F,0x0160,0x017C,0x017D
- dc.w 0x7FFF,0x003B,0x0075,0x0076,0x008D,0x008E
- dc.w 0x0090,0x0091,0x00EC,0x00ED,0x0109,0x010A
- dc.w 0x0126,0x0127,0x0146,0x014C,0x0158,0x0159
- dc.w 0x015B,0x015C,0x017D,0x017E,0x7FFF,0x003C
- dc.w 0x007A,0x007B,0x007E,0x007F,0x008D,0x0091
- dc.w 0x0095,0x0096,0x0098,0x0099,0x00D2,0x00D3
- dc.w 0x0108,0x0109,0x0125,0x0126,0x0158,0x015C
- dc.w 0x0160,0x0161,0x0163,0x0164,0x0178,0x0179
- dc.w 0x7FFF,0x003D,0x0089,0x008A,0x009D,0x009E
- dc.w 0x00D1,0x00D2,0x00EB,0x00EC,0x0107,0x0108
- dc.w 0x0124,0x0125,0x0154,0x0155,0x0168,0x0169
- dc.w 0x0179,0x017A,0x017E,0x017F,0x7FFF,0x003E
- dc.w 0x0076,0x0077,0x007D,0x007E,0x009E,0x009F
- dc.w 0x00EA,0x00EB,0x0106,0x0107,0x0123,0x0124
- dc.w 0x0169,0x016A,0x017F,0x0180,0x7FFF,0x003F
- dc.w 0x0088,0x0089,0x008C,0x0092,0x0096,0x0097
- dc.w 0x0099,0x009A,0x009F,0x00A5,0x00D0,0x00D1
- dc.w 0x0105,0x0106,0x0122,0x0123,0x0153,0x0154
- dc.w 0x0157,0x015D,0x0161,0x0162,0x0164,0x0165
- dc.w 0x016A,0x0170,0x017A,0x017B,0x0180,0x0181
- dc.w 0x7FFF,0x0040,0x009A,0x009B,0x00CF,0x00D0
- dc.w 0x00E9,0x00EA,0x0104,0x0105,0x0121,0x0122
- dc.w 0x0165,0x0166,0x7FFF,0x0041,0x0077,0x0078
- dc.w 0x007C,0x007D,0x008B,0x008C,0x009B,0x009D
- dc.w 0x00A5,0x00A6,0x00CE,0x00CF,0x00E8,0x00E9
- dc.w 0x0103,0x0104,0x0120,0x0121,0x0156,0x0157
- dc.w 0x0166,0x0168,0x0170,0x0171,0x017B,0x017C
- dc.w 0x0181,0x0182,0x7FFF,0x0042,0x0087,0x0088
- dc.w 0x0092,0x0093,0x0097,0x0098,0x009D,0x00A0
- dc.w 0x00A4,0x00A6,0x00CD,0x00CE,0x00E7,0x00E8
- dc.w 0x0102,0x0103,0x011F,0x0120,0x0152,0x0153
- dc.w 0x015D,0x015E,0x0162,0x0163,0x0168,0x016B
- dc.w 0x016F,0x0171,0x017C,0x017D,0x017F,0x0182
- dc.w 0x7FFF,0x0043,0x0070,0x0074,0x0078,0x007C
- dc.w 0x0080,0x0085,0x0087,0x008B,0x0093,0x0098
- dc.w 0x00A0,0x00A4,0x00CC,0x00CD,0x00E6,0x00E7
- dc.w 0x0101,0x0102,0x011E,0x011F,0x0141,0x0146
- dc.w 0x014C,0x0151,0x0152,0x0156,0x015E,0x0163
- dc.w 0x016B,0x016F,0x0173,0x0178,0x017D,0x017F
- dc.w 0x7FFF,0x0044,0x00CB,0x00CC,0x00E5,0x00E6
- dc.w 0x0100,0x0101,0x011D,0x011E,0x7FFF,0x0045
- dc.w 0x00CA,0x00CB,0x00E4,0x00E5,0x00FF,0x0100
- dc.w 0x011C,0x011D,0x7FFF,0x0046,0x00C8,0x00CA
- dc.w 0x00E3,0x00E4,0x00FE,0x00FF,0x011B,0x011C
- dc.w 0x7FFF,0x0047,0x00C7,0x00C8,0x00E2,0x00E3
- dc.w 0x00FD,0x00FE,0x011A,0x011B,0x7FFF,0x0048
- dc.w 0x00C5,0x00C7,0x00E1,0x00E2,0x00FC,0x00FD
- dc.w 0x0119,0x011A,0x7FFF,0x0049,0x00C4,0x00C5
- dc.w 0x00E0,0x00E1,0x00FA,0x00FC,0x0119,0x013C
- dc.w 0x7FFF,0x004A,0x00C2,0x00C4,0x00DF,0x00E0
- dc.w 0x00F9,0x00FA,0x7FFF,0x004B,0x00C0,0x00C2
- dc.w 0x00DE,0x00DF,0x00F8,0x00F9,0x7FFF,0x004C
- dc.w 0x00BE,0x00C0,0x00DC,0x00DE,0x00F7,0x00F8
- dc.w 0x7FFF,0x004D,0x00BC,0x00BE,0x00DB,0x00DC
- dc.w 0x00F6,0x00F7,0x7FFF,0x004E,0x00B9,0x00BC
- dc.w 0x00D9,0x00DB,0x00F5,0x00F6,0x7FFF,0x004F
- dc.w 0x00B5,0x00B9,0x00D8,0x00D9,0x00F4,0x00F5
- dc.w 0x7FFF,0x0050,0x00B1,0x00B5,0x00D7,0x00D8
- dc.w 0x7FFF,0x0051,0x00D5,0x00D7,0x7FFF,0x0052
- dc.w 0x00D3,0x00D5,0x7FFF,0x0053,0x00D1,0x00D3
- dc.w 0x7FFF,0x0054,0x00CF,0x00D1,0x7FFF,0x0055
- dc.w 0x00CD,0x00CF,0x7FFF,0x0056,0x00CB,0x00CD
- dc.w 0x7FFF,0x0057,0x00C8,0x00CB,0x7FFF,0x0058
- dc.w 0x00C5,0x00C8,0x7FFF,0x0059,0x00C2,0x00C5
- dc.w 0x7FFF,0x005A,0x00BF,0x00C2,0x00F4,0x00F5
- dc.w 0x7FFF,0x005B,0x0004,0x00B1,0x00BF,0x00F5
- dc.w 0x013C,0x01F3,0x7FFF,0x005D,0x0002,0x01F5
- dc.w 0x7FFF,0x005E,0x0001,0x01F6,0x7FFF,0x005F
- dc.w 0x0000,0x01F7,0x7FFF,0x7FFF
- };
- }
-
- void endLongData()
- {
- ;
- }
-
-
- /********************************************************************************
- DrawHackCont
-
- Creative things here ! (send me your best, I'll pay the postage :-)
-
- *********************************************************************************/
-
- void DrawHackCont()
- {
- return;
- }
-
-
-
- //********************************************************************************
- // B E G I N R G N B U I L D
- // run with a compile time flag once
- // to generate the rgn data. No outline
- // fonts at WDEF time, especially the
- // right ones ! (has to look good!)
-
-
- /********************************************************************************
- MakeRgnBg
-
- Make a file, find it, get the data. ;-)
-
- After making the Rgn with this routine, I used ResEdit to copy the data
- as hex and ran an mpw script to turn it into embedded data
-
- find •;replace -c ∞ /(?«4»)®1/ '0x'®1','
- find •;replace -c ∞ /(?«41»)®1,/ ®1∂n∂t∂t'dc.w '
-
- (fix the boundries after you run the script)
-
- *********************************************************************************/
- void MakeRgnBg()
- {
- PicHandle p;
- RgnHandle r;
- short resFileID;
-
- //Debugger();
- p = (Handle)GetResource( 'PICT', 128);
- r = PICT2Rgn( p);
- CreateResFile( "\ptemp");
- resFileID = OpenResFile( "\ptemp");
- AddResource( (Handle)r, 'tRgn', 1024, "\pwinBg");
- WriteResource( (Handle)r);
- CloseResFile( resFileID);
- return;
- }
-
- /********************************************************************************
- PICT2Rgn
-
- Using a PicHandle, create the region (1 bit) described by the drawn PICT.
- At present, make no adjustment for PICT frame.
-
- *********************************************************************************/
- RgnHandle PICT2Rgn( PicHandle p )
- {
- GrafPtr aGP;
- GrafPtr savPort;
- Rect gpRect;
- OSErr err;
- BitMap *resBM;
- RgnHandle rH;
-
- if(!p) return 0;
-
- gpRect = (**p).picFrame;
-
- rH = NewRgn();
-
- // Ditch the trap check, General Purpose -(NOT!)
-
- //if ( TrapAvailable( 0xA8D7)) {
- if ( CreateOffscreenBitMap( &aGP, &gpRect ) ) {
- //CheckAllocation( resBM=(BitMap*)NewPtr( sizeof(BitMap)));
- resBM=(BitMap*)NewPtr( sizeof(BitMap));
- GetPort( &savPort);
- SetPort( aGP);
- DrawPicture( p, &gpRect);
- /* Bad news iff aGP is a color port */
- *resBM = aGP->portBits;
-
- if ( err = BitMapToRegion( rH, resBM)) {
- DisposeRgn( rH );
- rH = 0;
- }
-
- ClosePort( aGP);
- DisposPtr( (Ptr)aGP);
-
- //gError->CheckOSError( err = QDError());
- DisposPtr( resBM->baseAddr);
- DisposPtr( (Ptr)resBM);
- SetPort( savPort);
- } else {
- DisposeRgn( rH);
- rH = 0;
- }
- //} else {
- // OpenRgn();
- // FrameRect( &gpRect);
- // CloseRgn( rH);
- //}
-
- return rH;
- }
-
-
- /********************************************************************************
- PICT2BitMap
-
- *********************************************************************************/
- BitMap *PICT2BitMap( PicHandle p )
- {
- GrafPtr aGP;
- GrafPtr savPort;
- Rect gpRect;
- BitMap *resBM;
-
- if(!p) return 0;
- resBM = (BitMap *)NewPtr( sizeof( BitMap ));
- //CheckAllocation( resBM = (BitMap *)NewPtr( sizeof( BitMap ) ) );
-
- gpRect = (**p).picFrame;
- if ( CreateOffscreenBitMap( &aGP, &gpRect ) ) {
-
- GetPort( &savPort ); SetPort( aGP );
- DrawPicture( p, &gpRect );
- /* Bad news iff really color port */
- *resBM = aGP->portBits;
- ClosePort(aGP);
- DisposPtr((Ptr)aGP);
- SetPort( savPort );
- } else {
- resBM->baseAddr = 0;
- resBM->rowBytes = 0;
- SetRect( &resBM->bounds, 0, 0, 0, 0 );
- }
-
- return resBM;
- }
-
-
-
- /********************************************************************************
- CreateOffscreenBitMap
- from DTS TechNote #41
- *********************************************************************************/
- Boolean CreateOffscreenBitMap(GrafPtr *newOffscreen, Rect *inBounds)
- {
- GrafPtr savePort;
- GrafPtr newPort;
-
- GetPort(&savePort); /* need this to restore thePort after OpenPort */
-
- newPort = (GrafPtr) NewPtr(sizeof(GrafPort)); /* allocate the grafPort */
- if (MemError() != noErr)
- return false; /* failed to allocate the off-screen port */
-
- /*
- the call to OpenPort does the following . . .
- allocates space for visRgn (set to screenBits.bounds)
- and clipRgn (set wide open)
- sets portBits to screenBits
- sets portRect to screenBits.bounds
- etc. (see IM I-163,164)
- side effect: does a SetPort(&offScreen)
- */
- OpenPort(newPort);
- /* make bitmap the size of the bounds that caller supplied */
- newPort->portRect = *inBounds;
- newPort->portBits.bounds = *inBounds;
- RectRgn(newPort->clipRgn, inBounds);/* avoid wide-open clipRgn, to be safe */
- RectRgn(newPort->visRgn, inBounds); /* in case newBounds is > screen bounds */
-
- /*rowBytes is size of row, it must be rounded up to an even number of bytes*/
- newPort->portBits.rowBytes =
- ((inBounds->right - inBounds->left + 15) >> 4) << 1;
-
- /* number of bytes in BitMap is rowBytes * number of rows */
- /* see notes at end of Technical Note about using _NewHandle
- rather than _NewPtr */
- newPort->portBits.baseAddr =
- NewPtr(newPort->portBits.rowBytes * (long)
- (inBounds->bottom - inBounds->top));
- if (MemError()!=noErr) { /* check to see if we had enough room for the bits */
- SetPort(savePort);
- ClosePort(newPort); /* dump the visRgn and clipRgn */
- DisposPtr((Ptr)newPort); /* dump the GrafPort */
- return false; /* tell caller we failed */
- }
- /* since the bits are just memory, let's clear them before we start */
- EraseRect(inBounds); /* OpenPort did a SetPort(newPort) so we are ok */
- *newOffscreen = newPort;
- SetPort(savePort);
- return true; /* tell caller we succeeded! */
- }
-
-
- /********************************************************************************
- DestroyOffscreenBitMap
- from DTS TechNote #41
- *********************************************************************************/
-
- void DestroyOffscreenBitMap(GrafPtr oldOffscreen)
- {
- ClosePort(oldOffscreen); /* dump the visRgn and clipRgn */
- DisposPtr(oldOffscreen->portBits.baseAddr); /* dump the bits */
- DisposPtr((Ptr)oldOffscreen); /* dump the port */
- }
-
-
-
-
- //**************************************************************************
- // E N D O F L I S T I N G